package run.bottle.app.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import run.bottle.app.exception.BadRequestException;
import run.bottle.app.model.dto.UserAndGroupDTO;
import run.bottle.app.model.entity.SysUser;
import run.bottle.app.security.context.SecurityContextHolder;
import run.bottle.app.security.token.AuthToken;
import run.bottle.app.service.AdminService;
import run.bottle.app.utils.BottleUtils;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * 首页
 *
 * @author lycheng
 * @date 2020/9/24 14:05
 */
@Controller
public class IndexController {

    @Autowired
    private AdminService adminService;

    @GetMapping
    public String index() {
        return "/index";
    }

    @GetMapping("/api/login")
    @ResponseBody
    public String login(String userId, Model mv) {
        //adminService.authCodeCheck("admin","123456");
        mv.addAttribute("userId",userId);
        return "登录成功";
    }

    @GetMapping("/api/user/{name}")
    @ResponseBody
    public String user(@PathVariable String name) {
        return "hello " + name;
    }
}
